package com.lottery.ruok.lottrey.ui.component;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.widget.TextView;

import com.lottery.ruok.lottrey.R;
import com.lottery.ruok.lottrey.bean.LHCLeftModel;

import butterknife.BindView;

public class LHCLeftMenuItemView extends BaseRelativeLayout {
    @BindView(R.id.option_text)
    TextView optionText;
    private LHCLeftModel data;

    public LHCLeftMenuItemView(Context context) {
        super(context);
    }

    public LHCLeftMenuItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public LHCLeftMenuItemView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void init(Context context, AttributeSet attrs, int defStyleAttr) {

    }

    @Override
    protected void initView(Context context) {
        setContentView(R.layout.lhc_option_layout);
    }

    @Override
    protected void load(Context context) {

    }

    public void setData(LHCLeftModel data) {
        this.data = data;
        updateView();
    }

    private void updateView() {
        if (data != null) {
            optionText.setText(data.getName());
            if (data.isSelected()) {
                optionText.setTextColor(Color.parseColor("#8454e4"));
            } else {
                optionText.setTextColor(Color.parseColor("#333333"));
            }
        }
    }

    public LHCLeftModel getData() {
        return data;
    }
}
